package com.simple_frame.utils;

import lombok.Data;

@Data
public class Result<T> {
    
    private Integer code;
    private String message;
    private T data;
    
    public static <T> Result<T> success() {
        Result<T> resultData = new Result<T>();
        resultData.setCode(200);
        resultData.setMessage("success");
        return resultData;
    }
    
    public static <T> Result<T> success(T data) {
        Result<T> resultData = success();
        resultData.setData(data);
        return resultData;
    }
    
    public static <T> Result<T> fail(String message, Integer code, T data) {
        Result<T> resultData = new Result<T>();
        resultData.setData(data);
        resultData.setCode(code);
        resultData.setMessage(message);
        return resultData;
    }
    
    public static <T> Result<T> fail(String message) {
        return fail(message, 500, null);
    }
    
    public static <T> Result<T> fail(String message, Integer code) {
        return fail(message, code, null);
    }
    
}
